<template>
    <div>
        <div style="background: #fff;border-radius: 6px 6px 0 0;padding: 10px;margin-bottom: 2px;">
            <a-button @click="goBack">返回</a-button>
        </div>

        <div style="background: #fff;border-radius:0 0 6px 6px;padding:  20px 20px 10px 20px;">
            <div style="color: #171a1d;font-family: PingFangSC-Medium;font-size: 17px;letter-spacing: 0;font-weight: 600;">
                全部参会人
                <!-- <el-button size="mini" style="position: absolute;right: 80px;">查询</el-button>
                <el-button size="mini" type="primary" style="position: absolute;right: 10px;">重置</el-button> -->
            </div>

            <el-table size="medium" height="500" :data="tableData" stripe style="width: 100%;margin-top: 10px;">
                <el-table-column prop="userNick" label="参会人" width="180"></el-table-column>
                <el-table-column prop="host" label="角色" width="180">
                    <template slot-scope="scope">{{ scope.row.host ? '主持人' : '参会人' }}</template>
                </el-table-column>
                <el-table-column prop="joinTime" label="入会时间">

                </el-table-column>
                <el-table-column prop="leaveTime" label="离会时间"></el-table-column>
                <el-table-column prop="duration" label="在会时长（毫秒）"></el-table-column>
                <el-table-column prop="attendStatus" label="状态">
                    <template slot-scope="scope">
                        <span v-show="scope.row.attendStatus==1">初始化</span>
                        <span v-show="scope.row.attendStatus==2">呼叫中</span>
                        <span v-show="scope.row.attendStatus==3">在会</span>
                        <span v-show="scope.row.attendStatus==4">入会失败</span>
                        <span v-show="scope.row.attendStatus==5">被踢</span>
                        <span v-show="scope.row.attendStatus==6">离会</span>
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </div>
</template>
  
<script>
import cmeduGateway from "@/api/cmeduGateway";
export default {
    name: "SetupTeacher",
    data() {
        return {
            expandedRowKeys: [],
            tableData: [],
            meetingId: '',
        };
    },
    mounted() {
        this.meetingId = this.$route.query.meetingId
        console.log(this.$route.query);
        this.getMeetingPeople()
    },
    methods: {
        formatData(time) {
            var date = new Date(time);
            var Y = date.getFullYear() + "-";
            var M =
                (date.getMonth() + 1 < 10
                    ? "0" + (date.getMonth() + 1)
                    : date.getMonth() + 1) + "-";
            var D = date.getDate() + " ";
            var h = date.getHours() + ":";
            var m = date.getMinutes() + ":";
            var s = date.getSeconds();
            return Y + M + D + h + m + s;
        },
        goBack() {
            this.$router.back();
        },
        async getMeetingPeople() {
            cmeduGateway.getMeetingMemberInfo((this.meetingId)).then((result) => {
                console.log(result);
                if (result.status == 200) {
                    this.tableData = result.data.memberModels
                    for (let index = 0; index < this.tableData.length; index++) {
                        this.tableData[index].joinTime = this.formatData(
                            this.tableData[index].joinTime
                        );

                        this.tableData[index].leaveTime = this.formatData(
                            this.tableData[index].leaveTime
                        );


                    }
                }
            }).catch((err) => {
                console.error(err);
            });
        }
    },
};
</script>

<style scoped></style>
